<?php

namespace Admin\Models\sys;

use Admin\Models\BaseModel;
class XhsysFunction extends BaseModel
{

    /**
     *
     * @var integer
     */
    public $iFunctionId;

    /**
     *
     * @var integer
     */
    public $iNodeId;

    /**
     *
     * @var string
     */
    public $sFunctionName;

    /**
     *
     * @var string
     */
    public $sFunctionUrl;

    /**
     *
     * @var string
     */
    public $sFunctionAttr;

    /**
     *
     * @var integer
     */
    public $bDelete;

    /**
     *
     * @var string
     */
    public $tCreateDate;

    /**
     *
     * @var string
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     */
    public $tLastModifyDate;

    /**
     *
     * @var string
     */
    public $iLastModifyUserId;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
        $this->setSource("'XHSys_Function'");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHSys_Function';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysFunction[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysFunction
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * 根据数据修改信息
     * 如果传入model，则在model基础上修改，否则新建记录
     *
     * @param $data
     * @param null $obj
     * @return null|XhsysFunction
     *
     * create by ck 20160822
     */
    public static function createRecord($data, $obj=null)
    {

        $obj = $obj ? $obj : new self;
        $obj->sFunctionName = $data['NodeName'];
        $obj->sFunctionUrl  = $data['FunctionUrl'];
        $obj->sFunctionAttr = $data['FunctionAttr'];
        $obj->bDelete = 0;
        return $obj;
    }

}
